package com.sangeng.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sangeng.domain.entity.Role;
import com.sangeng.domain.entity.User;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户表(User)表数据库访问层
 *
 * @author makejava
 * @since 2025-06-16 15:20:03
 */
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户id查询角色
     * @param id
     * @return
     */
    @Select("select distinct id, role_name, role_key, role_sort, status, del_flag, create_by, create_time, update_by, update_time, remark" +
            " from sys_role where id in (select role_id from sys_user_role where user_id=#{id}) " +
            "and status = '0'")
    List<Role> getRoleByUserId(Long id);
}

